<!-- UserController.php-->
<?php 
	require 'Model/DeModel.php';
	require 'Controller.php';
	class DeController extends Controller{
		public $model;
		function __Construct(){
			parent::__Construct();
			$this->model = new DeModel();
		}
		function department(){
			$model = new DeModel();
			$data = $model->getDeList();
			//转向用户列表页面
			$this->assign('department',$data);
			$this->display();
		}
        function desearch(){
			$dename = $_POST['dename'];
			$data = $this->model->getdeinfor($dename);
			include 'View/de/desearch.php';
		}

		function deform(){
			//转向添加用户页面
			include 'View/de/deform.php';
		}

		function departmentedit(){
			$id = $_GET['id'];
			$model = new DeModel();
			$result = $model->getUserByID($id);
			include 'View/de/departmentedit.php';
		}

		function videosearch(){
			$videoname = $_POST['videoname'];
			$model = new VideoModel();
			$data = $model->getvideoinfor($videoname);
			include dirname(dirname(__FILE__)).'/View/video/search.php';
		}

		function deupdate(){
			$id = $_GET['id'];
			$model = new DeModel();
			$result = $model->Updatedepartment($id);
			if($result){
				echo '修改成功'.'<a href="Admin.php?c=De&m=department">如果没有跳转，请点这里跳转</a>';
				header("refresh:3;Admin.php?c=De&m=department = Admin.php?c=De&m=department"); 	
			}else{
				echo '失败';
			}
		}

		function deldepartment(){
			$id = $_GET['id'];
			$model = new Demodel();
			$result = $model->Deldepartment($id);
			if($result){
				echo '删除成功'.'<a href="Admin.php?c=De&m=department">如果没有跳转，请点这里跳转</a>';
				header("refresh:3;Admin.php?c=De&m=department = Admin.php?c=De&m=department"); 
			}else{
				echo '删除失败';
			}
		}

		function addde(){
			//获取表单的数据
			//调用model中的addUser方法，添加到数据库中
			//var_dump($_POST);
			$data = $_POST;
			$model = new DeModel();
			$result = $model->addde($data);
			//如果成功，输出，转到列表页面
			if($result){
				echo '添加成功'.'<a href="Admin.php?c=De&m=department">如果没有跳转，请点这里跳转</a>';
				header("refresh:3;Admin.php?c=De&m=department = Admin.php?c=De&m=department"); 
			}else{
				echo '失败'; 
			}

		}
	}
 ?>